home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre3.z / postgre3 / src / lib / H / planner / internal.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  3.8 KB  |  148 lines

  1.  
  2. /*     
  3.  *      FILE
  4.  *         internal
  5.  *     
  6.  *      DESCRIPTION
  7.  *         Definitions required throughout the query optimizer.
  8.  *     
  9.  */
  10. /* RcsId ("$Header: /private/postgres/src/lib/H/planner/RCS/internal.h,v 1.15 1992/08/10 21:42:42 mer Exp $"); */
  11.  
  12. /*     
  13.  */
  14.  
  15. /*    
  16.  *        ---------- SHARED MACROS
  17.  *    
  18.  *         Macros common to modules for creating, accessing, and modifying
  19.  *        query tree and query plan components.
  20.  *        Shared with the executor.
  21.  *    
  22.  */
  23.  /* provide ("internal"); */
  24.  
  25. #include "nodes/nodes.h"
  26. #include "nodes/primnodes.h"
  27. #include "nodes/plannodes.h"
  28. #include "parser/parsetree.h"
  29. #include "nodes/relation.h"
  30. #include "catalog/pg_index.h"
  31. #include "tmp/c.h"
  32.  
  33. /* XXX - versions don't work yet, so parsetree doesn't have them,
  34.    I define the constant here just for the heck of it - jeff */
  35.  
  36. /*   parse tree manipulation routines */
  37.  
  38.  
  39.  
  40. /*    
  41.  *        ---------- GLOBAL VARIABLES
  42.  *    
  43.  *        These *should* disappear eventually...shouldn't they?
  44.  *    
  45.  */
  46.  
  47. /* from the parse tree: */
  48. extern LispValue _query_result_relation_; /*   relid of the result relation */
  49. extern int _query_command_type_;    /*   command type as a symbol */
  50. extern int _query_max_level_;      /*   max query nesting level */
  51. extern LispValue _query_range_table_;     /*   relations to be scanned */
  52.  
  53. /*     internal to planner:  */
  54. extern List _base_relation_list_;    /*   base relation list */
  55. extern List _join_relation_list_;    /*   join relation list */
  56. extern bool _query_is_archival_;       /*   archival query flag */
  57.  
  58. char *save_globals ARGS((void ));
  59. void restore_globals ARGS((char *pgh ));
  60.  
  61. extern int NBuffers;
  62. /*
  63.  *        System-dependent tuning constants
  64.  *    
  65.  */
  66.  
  67. #define _CPU_PAGE_WEIGHT_  0.065      /* CPU-to-page cost weighting factor */
  68. #define _PAGE_SIZE_    8192           /* BLCKSZ (from ../h/bufmgr.h) */
  69. #define _MAX_KEYS_     INDEX_MAX_KEYS /* maximum number of keys in an index */
  70. #define _TID_SIZE_     6              /* sizeof(itemid) (from ../h/itemid.h) */
  71.  
  72. /*    
  73.  *        Size estimates
  74.  *    
  75.  */
  76.  
  77. /*     The cost of sequentially scanning a materialized temporary relation
  78.  */
  79. #define _TEMP_SCAN_COST_     10
  80.  
  81. /*     The number of pages and tuples in a materialized relation
  82.  */
  83. #define _TEMP_RELATION_PAGES_         1
  84. #define _TEMP_RELATION_TUPLES_     10
  85.  
  86. /*     The length of a variable-length field in bytes
  87.  */
  88. #define _DEFAULT_ATTRIBUTE_WIDTH_ (2 * _TID_SIZE_)
  89.  
  90. /*    
  91.  *        Flags and identifiers
  92.  *    
  93.  */
  94.  
  95. /*     Identifier for UNION (nested dot) variable type  */
  96.  
  97. #define _UNION_TYPE_ID_    UNION
  98.  
  99. /*     Identifier for (sort) temp relations   */
  100. #define _TEMP_RELATION_ID_   -1
  101.  
  102. /*     Identifier for invalid relation OIDs and attribute numbers for use by
  103.  *     selectivity functions
  104.  */
  105. #define _SELEC_VALUE_UNKNOWN_   -1
  106.  
  107. /*     Flag indicating that a clause constant is really a parameter (or other 
  108.  *         non-constant?), a non-parameter, or a constant on the right side
  109.  *        of the clause.
  110.  */
  111. #define _SELEC_NOT_CONSTANT_   0
  112. #define _SELEC_IS_CONSTANT_    1
  113. #define _SELEC_CONSTANT_LEFT_  0
  114. #define _SELEC_CONSTANT_RIGHT_ 2
  115.  
  116. extern LispValue joinmethod_clauses ARGS((JoinMethod node));
  117. extern LispValue joinmethod_keys ARGS((JoinMethod node));
  118.  
  119. extern LispValue SearchSysCacheGetAttribute();
  120. extern LispValue TypeDefaultRetrieve();
  121.  
  122. #define retrieve_cache_attribute SearchSysCacheGetAttribute
  123.  
  124.  
  125. #define or_clause_p or_clause
  126. /*
  127. #define INDEXSCAN  20
  128. #define SEQSCAN    21
  129. #define NESTLOOP   22
  130. #define HASHJOIN   23
  131. #define MERGESORT  24
  132. #define SORT       25    
  133. #define HASH       26
  134. #define MATERIAL   27
  135. */
  136. extern TLE MakeTLE();
  137. extern void set_joinlist();
  138.  
  139. #define TOLERANCE 0.000001
  140.  
  141. #define FLOAT_EQUAL(X,Y) ((X) - (Y) < TOLERANCE)
  142. #define FLOAT_IS_ZERO(X) (FLOAT_EQUAL(X,0.0))
  143.  
  144. extern int BushyPlanFlag;
  145. #define deactivate_joininfo(joininfo)    set_inactive(joininfo, true)
  146. #define joininfo_inactive(joininfo)    get_inactive(joininfo)
  147.  
  148.